<script language="JavaScript">
//<!--
	function submitForm() {
		if(document.getElementById('item_form')) {
			document.getElementById('item_form').submit();
		}
	}
	
	function validateForm(frm,physicalCopy) {			
		var alertMsg = "";

		if (frm.title.value == "")
			alertMsg = alertMsg + "Title is required.<br>";
		
		if (physicalCopy) {
			//make sure this physical copy is supposed to have a barcode
			//	if it is, there will be an input element for it in the form
			if( (document.getElementById('barcode') != null) && (document.getElementById('barcode').value == '') )
				alertMsg = alertMsg + "Barcode is required.<br />";
		}
		else if((frm.documentType.value == "DOCUMENT") && (frm.userFile.value == "")) {
			alertMsg = alertMsg + "You must choose a file to upload.<br />";
		}
		else if((frm.documentType.value == "URL") && (frm.url.value == "")) {
			alertMsg = alertMsg + "URL is required.<br />";
		}
		
		if (!alertMsg == "") { 
			document.getElementById('alertMsg').innerHTML = alertMsg;
			return false;
		}					
	}
//-->
</script>
		
<form id="item_form" name="item_form" <?php	
if($this->item->getItemGroup() == 'ELECTRONIC'){ 
	?>enctype="multipart/form-data" <?php	
} 
?>action="index.php?cmd=editItem" method="post" onSubmit="return validateForm(this,false);">		

	<input type="hidden" name="submit_edit_item_meta" value="submit" />
	<input type="hidden" name="itemID" value="<?php print($this->item->getItemID()); ?>" />
	<?php 
		$this->getDisplayer()->displayHiddenFields($this->dubArray); //add duplication info as hidden fields 
	?>	
<?php	if($this->editReserve) { ?>
	<input type="hidden" name="reserveID" value="<?php print($this->reserve->getReserveID()); ?>" />	
<?php	} ?>
			
	<div id="item_meta" class="displayArea">		
<?php
		//show reserve details block
		
		if($this->editReserve) {
			$this->forward('displayEditItemReserveDetails'); //$reserve
		}
		//show item source
		$this->forward('displayEditItemSource'); // $item
		//show item details
		$this->forward('displayEditItemItemDetails'); // $item
?>
	<strong style="color:#FF0000;">*</strong> <span class="helperText">= required fields</span>
	</div>
	<div style="padding:10px; text-align:center;">
		<input type="button" name="submit_edit_item_meta" value="Save Changes" onclick="javascript: submitForm();">
	</div>
</form>		
<?php
		
//show item/reserve notes
if( Account_Rd::atLeastStaff() ) {	//show ajax to staff and above
	$this->forward('displayEditItemNotesAJAX'); 
}
else {	//show normal notes to everyone else
	$this->forward('displayEditItemNotes');
}